/********************************************************************************
 *      Copyright:  (C) 2024 LiYi<1751425323@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  socket_pack.h
 *    Description:  This file 
 *
 *        Version:  1.0.0(18/04/24)
 *         Author:  LiYi <1751425323@qq.com>
 *      ChangeLog:  1, Release initial version on "18/04/24 22:40:03"
 *                 
 ********************************************************************************/



#ifndef _SOCKET_PAK_H_
#define _SOCKET_PAK_H_

#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>


#include "logger.h"


typedef struct socket_ctx_s
{
	char	host[64];
	int		port;
	int		fd;
}socket_ctx_t;

int socket_init(socket_ctx_t *sock,char *host, int port);


int sock_conncet(socket_ctx_t *sock);

int socket_write(int connfd, char *buf,int bytes);

int socket_read(int connfd, char *buf,int bytes);

int  socket_close(socket_ctx_t *sock);

#endif

